﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses
Imports Telerik.WebControls

Public Class ViewHotelCost
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim strSql As String
        'strSql = "select * from ptn_HotelCost order by Id desc"
        'Fill_Grid_Bind(gvHotelCost, strSql)
    End Sub

    Protected Sub bindGridView()
        'Fill_Grid(radGrdCost, "select hc.*, h.Name as HotelName, (select Name from MealType where h.MealType=id) MealType, rt.Name as RoomType, rc.Name as RoomCategory from HotelCost hc inner join Hotels h on h.Id=hc.HotelId inner join RoomType rt on rt.Id=hc.RoomTypeId inner join RoomCategory rc on rc.Id=hc.RoomCategoryId")
        Fill_Grid(radGrdCost, "select hc.Id, CONVERT(VARCHAR(10), hc.StartDate, 103) StartDate, CONVERT(VARCHAR(10), hc.EndDate, 103) EndDate, hc.HotelId, hc.RoomCategoryId, hc.RoomTypeId, hc.Cost, hc.IsActive, hc.CreatedOn, hc.UpdatedOn, hc.MealType, hc.ClientType, h.Name as HotelName, (select Name from ptn_MealType where hc.MealType=id) MealTypeId, rt.Name as RoomType, rc.Name as RoomCategory from ptn_HotelCost hc inner join ptn_Hotels h on h.Id=hc.HotelId inner join ptn_RoomType rt on rt.Id=hc.RoomTypeId inner join ptn_RoomCategory rc on rc.Id=hc.RoomCategoryId")
    End Sub

    'Protected Function SetNavigateUrl(ByVal input As Object)
    '    Dim Url As String
    '    Url = "EditHotelCost.aspx?id=" + input.ToString()
    '    Return Url
    'End Function

    Protected Sub radGrdCost_NeedDataSource(ByVal source As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs) Handles radGrdCost.NeedDataSource
        bindGridView()
    End Sub

    Protected Sub radGrdCost_DeleteCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles radGrdCost.DeleteCommand
        Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ID").ToString
        Try
            Insert_Update_Delete_Record("delete from ptn_HotelCost where id=" & ID)
        Catch ex As Exception
            lblMsg.Text = "Unable to Delete Record. Reason: " + ex.Message
            lblMsg.ForeColor = Drawing.Color.Red
            e.Canceled = True
        End Try
    End Sub

End Class